// pages/detail/Join/Join.js
let app = getApp();
let testAddr = app.globalData.testAddr;
let imgurl=app.globalData.imgurl;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    pageindex:1,
    allPro:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that = this;
    that.getjoin();
  },
  // 招商加盟
  getjoin: function() {
    var that = this;
    var pageindex=that.data.pageindex;
    var allPro = that.data.allPro
    app.util.request({
      url: testAddr + "company/getCompanyInfo?pageIndex=" + pageindex,
      method: "POST",
      data: {
         
      },
      success: function(res) {
        if (res.data.errorCode == 0 && res.data.errorCode != undefined){
          // var joinform = res.data.result
          var jsonStr = res.data.result
          if (typeof jsonStr != 'object' && jsonStr != '') {
            jsonStr = jsonStr.replace(/\ufeff/g, "");//重点
            var jsonStr = JSON.parse(jsonStr);
          }
          for(var i=0;i<jsonStr.length;i++){
            if (jsonStr[i].logoUrl) {
              jsonStr[i].logoUrl = imgurl+'logo/' + jsonStr[i].logoUrl
            }
          }
          that.setData({
            jsonStr: jsonStr
          })
          if (jsonStr.length != 0) {
            that.setData({
              pageindex: pageindex + 1
            })
            allPro = allPro.concat(jsonStr)
          }
        }
        that.setData({
          allPro: allPro
        })
        // console.log(allPro)
      }
    })
  },
  // 跳转当前公司详情页
  gotopage:function(e){
    var id = e.currentTarget.id
    wx.navigateTo({
      url: '../firm/firm?id='+id,
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {
   var that =this;
    that.getjoin();

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})